package com.maslyk.invitation.to;

import com.maslyk.invitation.service.MD5Service;

/**
 *
 * @author kris
 */
public class UserPassword
{
    private String currentPass;
    private String newPass;
    private String newPassRepeted;

    public String getCurrentPass()
    {
        return currentPass;
    }

    public void setCurrentPass(String currentPass)
    {
        this.currentPass = currentPass;
    }

    public String getNewPass()
    {
        return newPass;
    }

    public void setNewPass(String newPass)
    {
        this.newPass = newPass;
    }

    public String getNewPassRepeted()
    {
        return newPassRepeted;
    }

    public void setNewPassRepeted(String newPassRepeted)
    {
        this.newPassRepeted = newPassRepeted;
    }

    public boolean isValid(String currentMD5)
    {
        if(newPass == null ||
           newPass.length() == 0 ||
           !newPass.equals(newPassRepeted) ||
           !currentMD5.equals(MD5Service.generateHexString(currentPass)))
            return false;

        return true;
    }

    public String getNewEncodedPassword()
    {
        return MD5Service.generateHexString(newPass);
    }
}
